package com.itshen.mapper;

import com.itshen.dto.ItemDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ItemMapper {

    @Select("select * from item")
    List<ItemDTO> search();

    @Select("select * from item where id = #{id}")
    ItemDTO getById(Long id);

    void updateById(ItemDTO item);

    @Update("update item set stock=stock-#{stock} where item_id=#{itemId}")
    int updateNumByItemId(Long itemId, Integer num);
}
